<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta charset="utf-8">
	<title>教育云平台-登陆</title>
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/public/bootstrap/css/bootstrap.css"/>
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/public/bootstrap/css/bootstrap-responsive.css"/>
	<link rel="stylesheet" type="text/css" href="/EECloud/resource/css/global.css"/>
	<script type="text/javascript" src="/EECloud/resource/jquery/jquery.js"></script>
	<style type="text/css">

		.row-fluid .span6{
			text-align: center;
			height: auto;
			/*background-color: black;*/
		}

		#reg > li > a{
			padding: 15px 5px;
		}
		.control-group{
			margin-right: 0px;
			margin-left: 0px;
		}

		.login-box{
			margin: 10px auto;
			background-color:;
			width: 780px;
			/*padding-bottom: 20px;*/
			display: block;
			overflow: hidden;
			padding: 20px 0;
			border-bottom: 1px solid #E5E5E5;

		}
		.login-content{
			display: block;
			float: left;

		}

		.login-section1{
			width: 375px;
			/*height: 200px;*/
			border-right: 1px solid #E5E5E5;
			float: left;
		}

		.login-section2{
			width: 374px;
			/*height: 200px;*/
			float: right;
			/*background-color: black;*/
		}

		.hero-unit{
			background-color: white;
		}


	</style>
</head>
<body>
	<div class="container-fluid" style="min-width:650px">
		<div class="navbar navbar-inverse">
			<div class="navbar-inner">

				<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
	              <span class="icon-bar"></span>
	              <span class="icon-bar"></span>
	              <span class="icon-bar"></span>
	            </button>

				<a  class="brand" href="/EECloud/index.php/index" >教育云平台</a>
				<ul class="nav">
					<li class=""><a href="/EECloud/index.php/index">首页</a></li>
					<li><a href="#">关于</a></li>
					<li><a href="#">联系</a></li>
				</ul>
				<ul class="nav" id="reg" style="float:right;font-size:12px">
					<!-- <?php if(empty($userName)):?> -->
					<li style="padding: 15px 5px;color:red">您还未登录！</li>
					<li style="padding:15px 0px">|</li>
					<li><a href="/EECloud/index.php/login">登录</a></li>
					<li style="padding:15px 0px">|</li>
					<li><a href="/EECloud/index.php/register">注册</a><li>
					<li style="padding:15px 0px">|</li>
					<li><a href="">客户端下载</a><li>
					<!-- <?php else: ?> -->
					<li><a href="/EECloud/index.php/login"><?=$userName?></a></li>
					<li style="padding:15px 0px">|</li>
					<!-- <?php endif;?> -->
				</ul>
			</div>
		</div>
	</div>

	<div class="container-fluid" >
		<div class="login-box">
			<div class="login-header">
				<legend id="warn">会员登录</legend>
			</div>
			<div class="login-content">
				<div class="login-section1">
					<table>
						<tr>
							<td style="padding-bottom:10px;padding-right:20px">账号:</td>
							<td><input type="text" id="userName" value="<?=$userName;?>"/></td>
						</tr>
						<tr>
							<td style="padding-bottom:10px;padding-right:20px">密码:</td>
							<td><input type="password" id="password"/></td>
						</tr>
						<tr>
							<td></td>
							<td><input type="checkbox" style="margin-bottom:5px;margin-right:5px" name="rmbPw" id="rmbPw" value=""/><span style="color:red;font-size:12px">记住我</span></td>
						</tr>
						<tr>
							<td></td>
							<td>
								<input type="hidden" id="redirect" value="<?=isset($_GET['redirect'])?$_GET['redirect']:"";?>">
								<a href="javascript:void(0);" class="btn btn-primary btn-large" style="margin-top:5px;margin-bottom:15px" id="login">登&nbsp;&nbsp;录</a>
								<a href="javascript:void(0);" style="font-size:12px;margin-left:10px">忘记密码</a>
							</td>
							
						</tr>
						<tr>
							<td>第三方登录</td>
							<td>
								<span><a href=""><img src="/EECloud/resource/img/sinat.png" ></a></span>
								<span><a href=""><img src="/EECloud/resource/img/qq.png"></a></span>
								<span><a href=""><img src="/EECloud/resource/img/baidu.png" ></a></span>
							</td>
						</tr>
					</table>
				</div>
				<div class="login-section2">
					<div class="hero-unit">
						<h3>欢迎加入教育云平台</h3>
						<div style="font-size:12px;color:red">
							<span>还没有云平台账号？</span>
							<span style="margin-left:50px">查找资源？</span>
						</div>
						<a href="/EECloud/index.php/register" class="btn btn-primary">立即注册 &raquo;</a>
						<a href="" class="btn btn-primary" style="margin-left:35px">公共云平台 &raquo;</a>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">	

		function checkUserName(){
			var userName = $("#userName").val();
			if(userName == ""){
				$("#userName").parent().append("<span class='unError'>请输入用户名</span>");
				return false;
			}
		}

		function checkPassword(){
			var password = $("#password").val();
			if(password == ""){
				$("#password").parent().append("<span class='pwError'>请输入密码</span>");
				return false;
			}
		}

		$(document).ready(function(){

			$("#userName").focus(function(){
				$(".loginError").remove();
				$(".unError").remove();
			});

			$("#password").focus(function(){
				$(".loginError").remove();
				$(".pwError").remove();
			});

			$("#userName").blur(function(){
				checkUserName();
			});

			$("#password").blur(function(){
				checkPassword();
			});

			$("#login").click(function(){

				var password = $.trim($("#password").val());
				var userName = $.trim($("#userName").val());
				var redirect = $("#redirect").val();
				var rmbPw = $("#rmbPw")[0].checked;
				// alert(rmbPw);return;
				// alert(redirect);
				if(userName == ""){
					$(".unError").remove();
					$("#userName").parent().append("<span class='unError'>请输入用户名</span>");
					return false;
				}else if(password == ""){
					$(".pwError").remove();
					$("#password").parent().append("<span class='unError'>请输入密码</span>");
					return false;
				}else if(userName != "" && password != ""){
					$.post('/EECloud/index.php/login/ajax_check_login', 'userName=' + userName + '&password=' + password, function(data){
						
						if(!data.success){
							$(".loginError").remove();
							$("#warn").append("<span class='loginError'>" + data.msg + "</span>");
							return false;
						}else{
							
							var url = '/EECloud/index.php/login/register?userId=' + data.msg + '&rmbPw=' + rmbPw + '&userName=' + userName;
							// alert(redirect);
							if(redirect != ""){
								// alert(redirect);
								url += '&redirect=' + redirect;
								// alert(url);
							}
							window.location.href = url;
						}
					},'json');
				}
			});

		});

		$("#password").keyup(function(event){
				        if(event.keyCode == 13){
				             $("#login").trigger("click");
				        }
		});
	</script>
</body>
</html>